function KDE_kerchoice

kerfig=figure( ...
   'Visible','on', ...
   'Name','Kernel Choice', ...
   'Units','Normalized',...
   'Tag','KDE_KCHOI',...
   'NumberTitle','off');

uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.3,.85,.4,.1], ...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.5,...
        'String','Kernel Choice');

% predefined kernels
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.1,.73,.4,.1], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'String','Predefined kernels:');
kchoice=uicontrol( ...
        'Style','popup', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.4,.79,.25,0.05], ...
        'String',' Epanechnikov| Quartic| Gaussian| Rectangular| Triangular', ...
        'Tag','KDE_KPREDEF');
%  button OK
predef1='kch=findobj(''Tag'',''KDE_KPREDEF'');preval=get(kch,''Value'');';
predef2='switch preval, case 1,  K=K_def(''epan''); case 2, K=K_def(''quar''); case 3, K=K_def(''gaus''); case 4, K=K_def(''rect''); case 5, K=K_def(''tria'');end; ';
predef3='mf=findobj(''Tag'',''KDE_MAIN'');udata=get(mf,''UserData'');udata.K=K;set(mf,''UserData'',udata);delete(gcf);KDE_kerdraw;';
uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.7,0.79,.05,0.05], ...
        'String','OK', ...
        'Callback',[predef1,predef2,predef3]);

% optimal kernels
mf=findobj('Tag','KDE_MAIN');
udata=get(mf,'UserData');
K=udata.K;
k=K.k;nu=K.nu;mu=K.mu;
ks=num2str(k);
nus=num2str(nu);
mus=num2str(mu);
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.1,.575,.6,.1], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'String','Optimal kernels (set parameters):');
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.1,.475,.4,.1], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'String','Order of the kernel (k):');
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.1,.4,.4,.1], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'String','Order of the derivative (\nu):');
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.1,.325,.4,.1], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.8 0.8 0.8], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'String','Smoothness (\mu):');
% edit fields
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.525,.515,.05,.065], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'Tag','KDE_KOPT_k',...
        'String',ks);
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.525,.44,.05,.065], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'Tag','KDE_KOPT_nu',...
        'String',nus);
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.525,.365,.05,.065], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'FontSize',0.4,...
        'Tag','KDE_KOPT_mu',...
        'String',mus);
%  button OK
optker1='KOPT_k=findobj(''Tag'',''KDE_KOPT_k'');k=eval(get(KOPT_k,''String''));';
optker2='KOPT_nu=findobj(''Tag'',''KDE_KOPT_nu'');nu=eval(get(KOPT_nu,''String''));';
optker3='KOPT_mu=findobj(''Tag'',''KDE_KOPT_mu'');mu=eval(get(KOPT_mu,''String''));';
optker4='K=K_def(''opt'',nu,k,mu);mf=findobj(''Tag'',''KDE_MAIN'');udata=get(mf,''UserData'');udata.K=K;set(mf,''UserData'',udata);delete(gcf);KDE_kerdraw;';
uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.7,0.3,.05,0.05], ...
        'String','OK', ...
        'Callback',[optker1,optker2,optker3,optker4]);
end % function

